package com.fone.player.play.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.fone.player.ApplicationManage;
import com.fone.player.R;
import com.fone.player.client.VgdetailRst;
import com.fone.player.play.fragment.VideoCommentFragment;
import com.fone.player.play.fragment.VideoRelatedFragment;

/**
 * 段视频模式视频详情页适配器
 * 
 * @author kongxiaojun
 * @since 2014-4-21
 * 
 */
public class ShortModeAdapter extends FragmentStatePagerAdapter {

	private final int[] TITLES = { R.string.video_info_tab_relate, R.string.video_info_tab_comment };
	/** 视频信息 */
	private VgdetailRst videoDetail;

	public ShortModeAdapter(FragmentManager fm, VgdetailRst videoDetail) {
		super(fm);
		this.videoDetail = videoDetail;
	}

	@Override
	public CharSequence getPageTitle(int position) {
		return ApplicationManage.getAplicationManageInstance().getString(TITLES[position]);
	}

	@Override
	public int getCount() {
		return TITLES.length;
	}

	@Override
	public Fragment getItem(int position) {
		Fragment fragment = null;
		switch (position) {
		case 0:// 相关
			fragment = VideoRelatedFragment.newInstances(videoDetail.linkurl);
			break;
		case 1:// 评论
			fragment = VideoCommentFragment.newInstances(videoDetail.addcommenturl, videoDetail.commenturl);
			break;
		}
		return fragment;
	}
	
	@Override
	public int getItemPosition(Object object) {
		return POSITION_NONE;
	}

}
